package com.yihang.jdbcDemo.ftp;

import com.github.drapostolos.rdp4j.*;
import com.github.drapostolos.rdp4j.spi.FileElement;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import sun.rmi.runtime.Log;


/**
 * @version v1.0
 * @类描述：
 * @项目名称：
 * @包名： com.kuangchi.weixin.sginin.service
 * @类名称：CertificationFtpListener
 * @创建人：YIHANG.XU
 * @创建时间：2020/10/289:15 下午
 * @修改人：YIHANG.XU
 * @修改时间：2020/10/289:15 下午
 * @修改备注：
 * @Copyright
 */
@Slf4j
public class CertificationFtpListener implements DirectoryListener, IoErrorListener, InitialContentListener {


    @Override
    public void fileAdded(FileAddedEvent event) throws InterruptedException {
        FileElement fileElement = event.getFileElement();
        log.info("文件开始处理");
        analysis(fileElement);

    }

    @Override
    public void fileRemoved(FileRemovedEvent event) throws InterruptedException {
        System.out.println("Removed: " + event.getFileElement());
    }

    @Override
    public void fileModified(FileModifiedEvent event) throws InterruptedException {
        FileElement fileElement = event.getFileElement();
        analysis(fileElement);
    }


    @Override
    public void initialContent(InitialContentEvent event) throws InterruptedException {
        System.out.println("I/O error ceased.");
    }

    @Override
    public void ioErrorRaised(IoErrorRaisedEvent event) throws InterruptedException {
        System.out.println("I/O error raised!");
        event.getIoException().printStackTrace();

    }

    @Override
    public void ioErrorCeased(IoErrorCeasedEvent event) throws InterruptedException {
        System.out.println("I/O error ceased.");
    }

    /**
     * 监控文件变化进行文件处理
     *
     * @param fileElement
     */
    public void analysis(FileElement fileElement) {
        String fileName = fileElement.getName();




    }


}


